{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Gate Expansions\n",
    "\n",
    "This notebook is intended to illustrate various gate expansions.\n",
    "Qubiter allows one to write on a single line in an English file \n",
    "many types of U(2) matrices with 0, 1, or more controls attached to it. However, there are well known identities for expanding such gates into\n",
    "a sequence of (1) single qubit rotations and (2) CNOTs with a single control.\n",
    "This is useful because most quantum computers (for example, IBM Quantum Experience)\n",
    "can only perform (1) and (2). Expansions into (1) and (2)\n",
    "can be performed automatically by Qubiter. Here is how.\n",
    "\n",
    "The expansions used by Qubiter \n",
    "were all discovered long ago. They can all be\n",
    "found in the following 1995 quantum computing paper:\n",
    "\n",
    "https://arxiv.org/abs/quant-ph/9503016\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First change your working directory to the qubiter directory in your computer, and add its path to the path environment variable."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "/home/rrtucci/PycharmProjects/qubiter/qubiter/jupyter_notebooks\n",
      "/home/rrtucci/PycharmProjects/qubiter\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "import sys\n",
    "print(os.getcwd())\n",
    "os.chdir('../../')\n",
    "print(os.getcwd())\n",
    "sys.path.insert(0,os.getcwd())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loaded OneQubitGate, WITHOUT autograd.numpy\n"
     ]
    }
   ],
   "source": [
    "from qubiter.CGateExpander import *\n",
    "from qubiter.SEO_writer import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "file_prefix = 'expansions_examples'\n",
    "num_qbits = 3\n",
    "emb = CktEmbedder(num_qbits, num_qbits, range(num_qbits))\n",
    "wr = SEO_writer(file_prefix, emb)\n",
    "\n",
    "trols1 = Controls(num_qbits)\n",
    "trols1.bit_pos_to_kind = {0: True}\n",
    "trols1.refresh_lists()\n",
    "\n",
    "trols2 = Controls(num_qbits)\n",
    "trols2.bit_pos_to_kind = {0: True, 1: False}\n",
    "trols2.refresh_lists()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write simple CNOT ( $\\sigma_X(1)^{n(0)}$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('simple cnot ( sigx(1)^n(0) )')\n",
    "wr.write_controlled_one_qbit_gate(1, trols1, OneQubitGate.sigx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write controlled sigy ( $\\sigma_Y(1)^{n(0)}$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('controlled sigy ( sigy(1)^n(0) )')\n",
    "wr.write_controlled_one_qbit_gate(1, trols1, OneQubitGate.sigy)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let $R = e^{i (\\theta_X \\sigma_X + \\theta_Y \\sigma_Y + \\theta_Z \\sigma_Z )}$.\n",
    "\n",
    "Write controlled Y,Z rotation ( $R(1)^{n(0)}$ with $\\theta_X = 0$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "# let exp(i*(radx*sigx + rady*sigy + radz*sigz)\n",
    "wr.write_NOTA('controlled Y,Z rotation ( rot(1)^n(0) with radx = 0 )')\n",
    "wr.write_controlled_one_qbit_gate(1, trols1, OneQubitGate.rot,\n",
    "                                 [0.0, np.pi/3, np.pi/4])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write controlled rotation ( $R(1)^{n(0)}$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('controlled rotation ( rot(1)^n(0) )')\n",
    "wr.write_controlled_one_qbit_gate(1, trols1, OneQubitGate.rot,\n",
    "                                 [np.pi/5, np.pi/3, np.pi/4])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write 2-controlled not ( $\\sigma_X(2)^{\\overline{n}(1)n(0)}$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('2-controlled not ( sigx(2)^(nbar(1)n(0)) )')\n",
    "wr.write_controlled_one_qbit_gate(2, trols2, OneQubitGate.sigx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write swap of 0 and 1 ( $E(0, 1)$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('swap of 0 and 1')\n",
    "wr.write_qbit_swap(0, 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Write swap of 1 and 2 controlled by 0 ( $E(1, 2)^{n(0)}$ )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.write_NOTA('swap of 1 and 2 controlled by 0')\n",
    "wr.write_controlled_qbit_swap(1, 2, trols1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "wr.close_files()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Look at\n",
    "\n",
    "* <a href=\"../io_folder/expansions_examples_3_eng.txt\">../io_folder/expansions_examples_3_eng.txt</a>\n",
    "* <a href=\"../io_folder/expansions_examples_3_ZLpic.txt\">../io_folder/expansions_examples_3_ZLpic.txt</a>\n",
    "\n",
    "to see the quantum circuit that was generated.\n",
    "Let's print the Picture file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table style='font-family:monospace'><tr><td style='border-right:1px solid red;'>1</td><td style='text-align:left;'><pre>NOTA\tsimple cnot ( sigx(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>2</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>3</td><td style='text-align:left;'><pre>NOTA\tcontrolled sigy ( sigy(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>4</td><td style='text-align:left;'><pre>|   Y---@</pre></td></tr><td style='border-right:1px solid red;'>5</td><td style='text-align:left;'><pre>NOTA\tcontrolled Y,Z rotation ( rot(1)^n(0) with radx = 0 )</pre></td></tr><td style='border-right:1px solid red;'>6</td><td style='text-align:left;'><pre>|   R---@</pre></td></tr><td style='border-right:1px solid red;'>7</td><td style='text-align:left;'><pre>NOTA\tcontrolled rotation ( rot(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>8</td><td style='text-align:left;'><pre>|   R---@</pre></td></tr><td style='border-right:1px solid red;'>9</td><td style='text-align:left;'><pre>NOTA\t2-controlled not ( sigx(2)^(nbar(1)n(0)) )</pre></td></tr><td style='border-right:1px solid red;'>10</td><td style='text-align:left;'><pre>X---O---@</pre></td></tr><td style='border-right:1px solid red;'>11</td><td style='text-align:left;'><pre>NOTA\tswap of 0 and 1</pre></td></tr><td style='border-right:1px solid red;'>12</td><td style='text-align:left;'><pre>|   <---></pre></td></tr><td style='border-right:1px solid red;'>13</td><td style='text-align:left;'><pre>NOTA\tswap of 1 and 2 controlled by 0</pre></td></tr><td style='border-right:1px solid red;'>14</td><td style='text-align:left;'><pre><--->---@</pre></td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "wr.print_pic_file(jup=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One can create new English and Picture files\n",
    "from those we just created simply\n",
    "by creating an object of the CGateExpander class.\n",
    "The new files contain an expansion of every line of the old files."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "ex = CGateExpander(file_prefix, num_qbits)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Look at\n",
    "\n",
    "* <a href=\"../io_folder/expansions_examples_X1_3_eng.txt\">../io_folder/expansions_examples_X1_3_eng.txt</a>\n",
    "* <a href=\"../io_folder/expansions_examples_X1_3_ZLpic.txt\">../io_folder/expansions_examples_X1_3_ZLpic.txt</a>\n",
    "\n",
    "to see the new expanded quantum circuit that was generated. (Note that\n",
    "the new files have the same names as the old ones except that an \"_X1\" has been \n",
    "added to the names of the old files).\n",
    "Let's print the new Picture file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table style='font-family:monospace'><tr><td style='border-right:1px solid red;'>1</td><td style='text-align:left;'><pre>NOTA\tsimple cnot ( sigx(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>2</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>3</td><td style='text-align:left;'><pre>NOTA\tcontrolled sigy ( sigy(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>4</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>5</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>6</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>7</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>8</td><td style='text-align:left;'><pre>NOTA\tcontrolled Y,Z rotation ( rot(1)^n(0) with radx = 0 )</pre></td></tr><td style='border-right:1px solid red;'>9</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>10</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>11</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>12</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>13</td><td style='text-align:left;'><pre>NOTA\tcontrolled rotation ( rot(1)^n(0) )</pre></td></tr><td style='border-right:1px solid red;'>14</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>15</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>16</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>17</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>18</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>19</td><td style='text-align:left;'><pre>NOTA\t2-controlled not ( sigx(2)^(nbar(1)n(0)) )</pre></td></tr><td style='border-right:1px solid red;'>20</td><td style='text-align:left;'><pre>|   X   |</pre></td></tr><td style='border-right:1px solid red;'>21</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>22</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>23</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>24</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>25</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>26</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>27</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>28</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>29</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>30</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>31</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>32</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>33</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>34</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>35</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>36</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>37</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>38</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>39</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>40</td><td style='text-align:left;'><pre>|   Rz  |</pre></td></tr><td style='border-right:1px solid red;'>41</td><td style='text-align:left;'><pre>|   X   |</pre></td></tr><td style='border-right:1px solid red;'>42</td><td style='text-align:left;'><pre>NOTA\tswap of 0 and 1</pre></td></tr><td style='border-right:1px solid red;'>43</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>44</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>45</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>46</td><td style='text-align:left;'><pre>NOTA\tswap of 1 and 2 controlled by 0</pre></td></tr><td style='border-right:1px solid red;'>47</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>48</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>49</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>50</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>51</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>52</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>53</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>54</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>55</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>56</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>57</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>58</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>59</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>60</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>61</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>62</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>63</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>64</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>65</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>66</td><td style='text-align:left;'><pre>|   Rz  |</pre></td></tr><td style='border-right:1px solid red;'>67</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>68</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>69</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>70</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>71</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>72</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>73</td><td style='text-align:left;'><pre>@---+---X</pre></td></tr><td style='border-right:1px solid red;'>74</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>75</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>76</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>77</td><td style='text-align:left;'><pre>|   X---@</pre></td></tr><td style='border-right:1px solid red;'>78</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>79</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>80</td><td style='text-align:left;'><pre>@---+---X</pre></td></tr><td style='border-right:1px solid red;'>81</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>82</td><td style='text-align:left;'><pre>@---X   |</pre></td></tr><td style='border-right:1px solid red;'>83</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>84</td><td style='text-align:left;'><pre>@---X   |</pre></td></tr><td style='border-right:1px solid red;'>85</td><td style='text-align:left;'><pre>|   R   |</pre></td></tr><td style='border-right:1px solid red;'>86</td><td style='text-align:left;'><pre>Rz  |   |</pre></td></tr><td style='border-right:1px solid red;'>87</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>88</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>89</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>90</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>91</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>92</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>93</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>94</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>95</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>96</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>97</td><td style='text-align:left;'><pre>X---+---@</pre></td></tr><td style='border-right:1px solid red;'>98</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>99</td><td style='text-align:left;'><pre>|   |   Rz</pre></td></tr><td style='border-right:1px solid red;'>100</td><td style='text-align:left;'><pre>|   @---X</pre></td></tr><td style='border-right:1px solid red;'>101</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>102</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>103</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>104</td><td style='text-align:left;'><pre>X---@   |</pre></td></tr><td style='border-right:1px solid red;'>105</td><td style='text-align:left;'><pre>R   |   |</pre></td></tr><td style='border-right:1px solid red;'>106</td><td style='text-align:left;'><pre>|   Rz  |</pre></td></tr></table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ex.wr.print_pic_file(jup=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "One can count the number of CNOTs in the newly created file by simply creating an object of class\n",
    "SEO_reader and printing the log file that this creates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of lines in file = 106\n",
      "Number of Elem. Ops = 99\n",
      "Number of CNOTS (SIGX with single control) = 41\n",
      "List of distinct variable numbers encountered (length=0)=\n",
      "[]\n",
      "List of distinct function names encountered (length=0)=\n",
      "[]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "rdr = SEO_reader(file_prefix + '_X1', num_qbits, write_log=True)\n",
    "rdr.print_log_file()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If a quantum circuit contains only qubit rotations and\n",
    "CNOTs, then its number of CNOTs is a measure of the time \n",
    "complexity of the circuit. Some would say it's even\n",
    "a measure of TIME. That's because single qubit rotations\n",
    "are simple in the sense that they act on a single qubit,\n",
    "whereas CNOTs are much less trivial because they\n",
    "represent two body interactions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {
    "height": "30px",
    "width": "252px"
   },
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
